home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / RAND / BM132A.LZH / bm_132a / screen.s < prev    next >
Encoding:
Text File  |  1995-11-16  |  4.7 KB  |  173 lines

  1. *=======================================================*
  2. *    Screen module: latest update 15/11/95        *
  3. *=======================================================*
  4.  
  5. *-------------------------------------------------------*
  6. *    Select new video mode & store old values    *
  7. *-------------------------------------------------------*
  8. select_video:
  9. *-------------------------------------------------------*
  10. *    Set up screen variables                *
  11. *-------------------------------------------------------*
  12.     move.w        #max_xres,scrwidth
  13. *-------------------------------------------------------*
  14. *    Store old video mode                *
  15. *-------------------------------------------------------*
  16.     push.w        #-1
  17.     push.w        #88
  18.     trap        #14
  19.     addq.l        #4,sp
  20.     move.w        d0,old_video
  21. *-------------------------------------------------------*
  22. *    Store old screen base                *
  23. *-------------------------------------------------------*
  24.     push.w        #2
  25.     trap        #14
  26.     addq.l        #2,sp
  27.     move.l        d0,old_screen
  28. *-------------------------------------------------------*
  29. *    Create new video mode for correct monitor    *
  30. *-------------------------------------------------------*
  31.     move.w        old_video,d0
  32.     and.w        #vga,d0
  33.     beq.s        .rgb
  34. .vga:    move.w        #true|lace|vga,d1
  35.     move.w        #240,scanlines
  36.     bra.s        .set
  37. .rgb:    move.w        #200,scanlines
  38.     move.w        old_video,d1
  39.     and.w        #pal,d1
  40.     or.w        #true,d1
  41. *-------------------------------------------------------*
  42. *    Set new video mode                *
  43. *-------------------------------------------------------*
  44. .set:    push.w        d1
  45.     push.w        #-1
  46.     push.l        ScreenPhy
  47.     push.l        ScreenLog
  48.     push.w        #5
  49.     trap        #14
  50.     lea        12(sp),sp
  51.     push.w        #88
  52.     trap        #14
  53.     addq.l        #4,sp
  54. *-------------------------------------------------------*
  55. *    Calculate screen height                *
  56. *-------------------------------------------------------*
  57.     move.w        SCAN_START.w,upper_border
  58.     move.w        SCAN_STOP.w,lower_border
  59.     bsr        adjust_scanlines
  60. *-------------------------------------------------------*
  61. *    Set background/border colour to black        *
  62. *-------------------------------------------------------*
  63.     move.l        $ffff9800.w,old_border
  64.     clr.l        $ffff9800.w
  65.     rts
  66.  
  67. *-------------------------------------------------------*
  68. *    Reset video mode & screens to old values    *
  69. *-------------------------------------------------------*
  70. restore_video:
  71. *-------------------------------------------------------*
  72. *    Reset screen base                *
  73. *-------------------------------------------------------*
  74.     move.l        old_screen,d0
  75.     move.l        d0,d1
  76.     lsr.w        #8,d0
  77.     move.l        d0,$ffff8200.w
  78.     move.b        d1,$ffff820d.w
  79. *-------------------------------------------------------*
  80. *    Reset border colour                *
  81. *-------------------------------------------------------*
  82.     move.l        old_border,$ffff9800.w
  83. *-------------------------------------------------------*
  84. *    Reset video mode & TOS screens            *
  85. *-------------------------------------------------------*
  86.     push.w        old_video
  87.     push.w        #-1
  88.     push.l        old_screen
  89.     push.l        old_screen
  90.     push.w        #5
  91.     trap        #14
  92.     lea        12(sp),sp
  93.     push.w        #88
  94.     trap        #14
  95.     addq.l        #4,sp
  96.     rts
  97.  
  98. *-------------------------------------------------------*
  99. *    Adjust vertical screen height            *
  100. *-------------------------------------------------------*
  101. adjust_scanlines:
  102. *-------------------------------------------------------*
  103.     tst.b        adjust
  104.     bne.s        .go
  105.     rts
  106. .go:    subq.b        #1,adjust
  107.     move.w        scanlines,d0
  108.     sub.w        height,d0
  109.     move.w        old_video,d3
  110.     and.w        #vga,d3
  111.     beq.s        .nvg
  112.     add.w        d0,d0
  113. .nvg:    move.w        upper_border,d1
  114.     move.w        lower_border,d2
  115.     add.w        d0,d1
  116.     sub.w        d0,d2
  117.     tst.w        d3
  118.     bne.s        .v2
  119.     and.w        #-2,d1
  120.     and.w        #-2,d2
  121.     or.w        #1,d1
  122.     or.w        #1,d2
  123. .v2:    move.w        d2,SCAN_STOP.w
  124.     move.w        d1,SCAN_START.w
  125.     rts
  126.  
  127. *-------------------------------------------------------*
  128. *    Allocate space for screenbuffers        *    
  129. *-------------------------------------------------------*
  130. allocate_screens:
  131. *-------------------------------------------------------*
  132.     Mxalloc        #(max_xres*max_yres*2)+256,STRAM_only
  133.     add.l        #255,d0
  134.     sub.b        d0,d0
  135.     move.l        d0,ScreenLog    
  136.     Mxalloc        #(max_xres*max_yres*2)+256,STRAM_only
  137.     add.l        #255,d0
  138.     sub.b        d0,d0
  139.     move.l        d0,ScreenPhy
  140.     Mxalloc        #(max_xres*max_yres*2)+256,STRAM_only
  141.     add.l        #255,d0
  142.     sub.b        d0,d0
  143.     move.l        d0,ScreenBak
  144. .end:    rts
  145.  
  146. *-------------------------------------------------------*
  147.         bss
  148. *-------------------------------------------------------*
  149.  
  150. scrwidth:    ds.w    1
  151. scanlines:    ds.w    1
  152. upper_border:    ds.w    1
  153. lower_border:    ds.w    1
  154.  
  155. old_video:    ds.w    1
  156. old_screen:    ds.l    1
  157. old_border:    ds.l    1
  158.  
  159. screen_ptrs:
  160. ScreenLog:    ds.l    1    
  161. ScreenBak:    ds.l    1    
  162. ScreenPhy:    ds.l    1    
  163.  
  164. screen:        ds.l    1
  165.  
  166. refresh:    ds.b    1
  167. adjust:        ds.b    1
  168.         even
  169.  
  170. *-------------------------------------------------------*
  171.         text
  172. *-------------------------------------------------------*
  173.